Task References

On this page:

calculateTimeDiff (time)

Purpose

The calculateTimeDiff task calculates the difference between two timestamps and returns the result between them as a duration.

Potential Use Case

You could use the calculateTimeDiff task if you need to determine the remaining time (or elapsed time) between a recorded timestamp and today's date.

Properties

Incoming Type Description
firstTime Object Required. The time to subtract from using the secondTime parameter.
secondTime Object Required. The time that is subtracted from the firstTime parameter.


Outgoing Type Description
timeDiff Object The difference between the two time values expressed as a duration in multiple units. For example:
"milliseconds": -2592000000
"seconds": -2592000
"minutes": -43200
"hours": -720
"days": -30
"months": -0.9856465225158627
"years": -0.08213721020965523

Examples

Example 1

In this IAP example:

  • The firstTime property is provided by the output of addDuration, another another task located elsewhere in the workflow. The reference variable provided by the other task is newtime.

  • The secondTime property is provided by the output of another task (referred to here as getTime) and the reference variable is time.

  • For this example, let's say the incoming value of secondTime is less than the incoming value of firstTime. Consequently, the outgoing timeDiff value will be a positive time reference such as: There are 'X' number of days between now and the future date.

    calculateTimeDiff01

Example 2

In this IAP example:

  • The firstTime property is provided by the output of getTime, another task located elsewhere in the workflow. The reference variable provided by the other task is time.

  • The secondTime property is provided by the output of another task (referred to here as addDuration) and the reference variable is newTime.

  • For this example, let's say the incoming value of secondTime is greater than the incoming value of firstTime. Consequently, the outgoing timeDiff value will be a negative time reference such as: The elapsed time since the firstTime deadline was surpassed by secondTime.

    calculateTimeDiff02